<!doctype html>
<html lang="en" class="fixed">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <title>添加学员</title>
    <link rel="apple-touch-icon" sizes="120x120" href="favicon/apple-icon-120x120.png">
    <link rel="icon" type="image/png" sizes="192x192" href="favicon/android-icon-192x192.png">
    <link rel="icon" type="image/png" sizes="32x32" href="favicon/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="favicon/favicon-16x16.png">
    <link rel="stylesheet" type="text/css"
          href="<?php xcho(loadSource('/assets/plugins/bootstrap/css/bootstrap.min.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/animate.css/animate.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/font-awesome/css/font-awesome.css')) ?>">
    <link rel="stylesheet"
          href="<?php xcho(loadSource('/assets/plugins/data-table/media/css/dataTables.bootstrap.min.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/ztree/css/zTreeStyle/zTreeStyle.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/app/css/style.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/layui/css/layui.css')) ?>" media="all">
    <link rel="stylesheet" href="<?php xcho(loadSource('/app/css/app.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/css/new_main.css')) ?>">
    
    <style>
        .pagination{
            margin: 0;
        }
        ul,li,ol,li{
            list-style: none;
        }
        body{
            background: #f4f4f4;
        }
        .addCourse{
            width: 900px;
            margin: 0 auto;
            padding: 20px;
            background: #fff;
        }
        .addCourse .addCourse-title{
            /*padding: 10px 0px;*/
            text-align: left;
        }
        .col-xs-4{
            margin-top: 15px;
        }
        .addCourse .addCourse-content .addCourse-cont h3{
            font-size: 12px;
            padding: 8px 10px;
            background: rgba(243,243,243,.5);
            margin-top: 0;
        }
        .addCourse .addCourse-content .addCourse-cont .cont-form{
            padding: 0 20px 20px;
        }
        .addCourse .addCourse-content .addCourse-cont .cont-form .form-row{
            margin-top: 20px;
        }
        .addCourse .addCourse-content .addCourse-cont .cont-form .form-row.linkage select{
            width: 100px;
        }
        .addCourse .addCourse-content .addCourse-cont .cont-form .form-row p{
            float: left;
        }
        .addCourse .addCourse-content .addCourse-cont .cont-form .form-row textarea{
            resize: none;
            border-radius: 5px;
            border: 1px #ccc solid;
            text-indent: 10px;
        }
        .addCourse .addCourse-content .addCourse-cont .cont-form span{
            margin-left: 40px;
        }
        .addCourse .addCourse-content .addCourse-cont .cont-form span:nth-of-type(1){
            margin-left: 0;
        }
        .addCourse .addCourse-content .addCourse-cont .cont-form select{
            /*width: 170px;*/
            border-radius: 5px;
            height: 24px;
            border:1px #ccc solid;
            font-size: 12px;
        }
        .addCourse .addCourse-content .addCourse-cont .addCourse-btn{
            width: 100%;
            height: 40px;
            padding:0 20px;
        }
        .addCourse .addCourse-content .addCourse-cont .addCourse-btn .addCourse-btn-cont{
            float: right;
        }
        .addCourse .addCourse-content .addCourse-cont .addCourse-btn .addCourse-btn-cont button{
            padding: 2px 10px;
            border:none;
            background: #1ab394;
            color:#fff;
            border-radius: 5px;
            color:#fff;
            margin-right: 10px;
            font-size: 12px;
        }
        .addCourse .addCourse-content .addCourse-cont .addCourse-btn .addCourse-btn-cont button:hover{
            background: #1ab394;
        }
        .addCourse .addCourse-content .addCourse-cont .addCourse-btn .addCourse-btn-cont button:nth-of-type(1){
            background: #fff;
            color:#888;
            border: 1px #ccc solid;
        }
    </style>
</head>

<body><?php include_once TPL_PATH . 'public/nav.phtml'; ?>

<div class="addCourse">
    <div class="addCourse-title">
        <ol class="breadcrumb">
            <li class="active">学员信息</li>
        </ol>
    </div>
    <div class="addCourse-content">
        <div class="addCourse-cont">
            <h3>基础信息</h3>
            <div class="cont-form">
                <div class="row">
                    <div class="col-xs-4">
                        <div class="input-group">
                            <span class="input-group-addon">学员名称：</span>
                            <input type="text" name="sname" class="form-control">
                        </div>
<!--                        <span data-name="sname" class="hidden_area" style="color: red;padding-top: 5px;display: none"></span>-->
                    </div>
                    <div class="col-xs-4">
                        <div class="input-group">
                            <span class="input-group-addon">联系手机：</span>
                            <input type="text" name="cellphone" class="form-control mobile">
                        </div>
                        <span data-name="cellphone" class="hidden_area" style="color: red;padding-top: 5px;display: none"></span>
                    </div>
                    <div class="col-xs-4">
                        <div class="input-group">
                            <span class="input-group-addon">家庭座机：</span>
                            <input type="text" name="telephone" class="form-control">
                        </div>
                        <span data-name="telephone" class="hidden_area" style="color: red;padding-top: 5px;display: none"></span>
                    </div>
                    <div class="col-xs-4">
                        <div class="input-group">
                            性别：
                            <select name="sex" id="sex">
                                <option value="">请选择</option>
                               <?php foreach ($sexList as $se) { ?>
                                <option value="<?php xcho($se['dict_value']) ?>"><?php xcho($se['cn_name']) ?></option>
                               <?php } ?>
                            </select>
                        </div>

                    </div>
                    <div class="col-xs-4">
                        <div class="input-group">
                            <span class="input-group-addon">年龄：</span>
                            <input type="text" name="age" class="form-control int">
                        </div>
                        <span data-name="age" class="hidden_area" style="color: red;padding-top: 5px;display: none"></span>
                    </div>
                    <div class="col-xs-4">
                        <div class="input-group">
                            <span class="input-group-addon">微信：</span>
                            <input type="text" name="wechat" class="form-control">
                        </div>
                        <span data-name="wechat" class="hidden_area" style="color: red;padding-top: 5px;display: none"></span>
                    </div>
                    <div class="col-xs-4">
                        <div class="input-group">
                            <span class="input-group-addon">QQ：</span>
                            <input type="text" name="qq" class="form-control int">
                        </div>

                    </div>
                    <div class="col-xs-4">
                        <div class="input-group">
                            <span class="input-group-addon">邮箱：</span>
                            <input type="text" name="email" class="form-control email">
                        </div>

                    </div>
                    <div class="col-xs-4">
                        <div class="input-group">
                            <span class="input-group-addon">家庭地址：</span>
                            <input type="text" name="home_address" class="form-control">
                        </div>
                        <span data-name="home_address" class="hidden_area" style="color: red;padding-top: 5px;display: none"></span>
                    </div>
                    <div class="col-xs-5">
                        <div class="form-row linkage">
                            <span>渠道来源：</span>
                            <select name="channel_id" class="channel">
                                <option value="">请选择</option>
                                <?php foreach ($channelList as $ch ) { ?>
                                <option value="<?php xcho($ch['id']) ?>"><?php xcho($ch['cn_name']) ?></option>
                                <?php } ?>
                            </select>
                        </div>
                        <span data-name="channel_id" class="hidden_area" style="color: red;padding-top: 5px;display: none"></span>
                    </div>
                    <div class="col-xs-7">
                        <div class="form-row linkage">
                            <span>地区<b style="visibility:hidden;"></b>：</span>
                            <select id="cmbProvince" name="province"></select>
                            <select id="cmbCity" name="city"></select>
                            <select id="cmbArea" name="county"></select>
                        </div>
                    </div>
                    <div class="col-xs-10">
                        <div class="form-row linkage">
                            <span>备注信息：</span>
                            <textarea name="remark" class="form-control"></textarea>
                        </div>
                        <span data-name="remark" class="hidden_area" style="color: red;padding-top: 5px;display: none"></span>
                    </div>
                </div>
                
            </div>
            <h3>学情信息</h3>
            <div class="cont-form">
                <div class="form-row">
                    <div class="row">
                        <div class="col-xs-4">
                            <div class="input-group">
                                <span class="input-group-addon">入学时间：</span>
                                <input type="date" name="admission_time"  class="form-control">
                            </div>
                        </div>
                        <div class="col-xs-4">
                            <div class="input-group">
                                <span class="input-group-addon">当前学校：</span>
                                <input type="text" name="school"  class="form-control">
                            </div>
                        </div>
                        <div class="col-xs-4">
                            <div class="input-group">
                                <span>年级：</span>
                                <select name="grade" id="">
                                    <option value="">请选择</option>
                                    <?php foreach ($gradeList as $gr) { ?>
                                        <option value="<?php xcho($gr['dict_value']) ?>"><?php xcho($gr['cn_name']) ?></option>
                                    <?php } ?>
                                </select>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <h3>相关信息</h3>
            <div class="cont-form">
                <div class="form-row">
                    <div class="row">
                        <div class="col-xs-4">
                            <div class="input-group">
                                <span class="input-group-addon">亲戚名称：</span>
                                <input type="text" name="relation1" class="form-control" placeholder="亲戚名称">
                            </div>
                        </div>
                        <div class="col-xs-4">
                            <div class="input-group">
                                <span class="input-group-addon">亲戚姓名：</span>
                                <input type="text" name="full_name1" class="form-control" placeholder="亲戚姓名">
                            </div>
                        </div>
                        <div class="col-xs-4">
                            <div class="input-group">
                                <span class="input-group-addon">亲戚手机：</span>
                                <input type="text" name="re_cellphone1" class="form-control mobile" placeholder="亲戚手机">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-row">
                    <div class="row">
                        <div class="col-xs-4">
                            <div class="input-group">
                                <span class="input-group-addon">亲戚名称：</span>
                                <input type="text" name="relation2" class="form-control" placeholder="亲戚名称">
                            </div>
                        </div>
                        <div class="col-xs-4">
                            <div class="input-group">
                                <span class="input-group-addon">亲戚姓名：</span>
                                <input type="text" name="full_name2" class="form-control" placeholder="亲戚姓名">
                            </div>
                        </div>
                        <div class="col-xs-4">
                            <div class="input-group">
                                <span class="input-group-addon">亲戚手机：</span>
                                <input type="text" name="re_cellphone2" class="form-control mobile" placeholder="亲戚手机">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <h3>跟进信息</h3>
            <div class="cont-form">
                <div class="form-row">
                    <div class="row">
                        <div class="col-xs-4">
                            <div class="input-group">
                                意向状态：
                                <select name="intention" id="">
                                    <option value="">请选择</option>
                                    <?php foreach ($intentionList as $in) { ?>
                                        <option value="<?php xcho($in['dict_value']) ?>"><?php xcho($in['cn_name']) ?></option>
                                    <?php } ?>
                                </select>
                            </div>
                        </div>
<!--                        <div class="col-xs-4">-->
<!--                            <div class="input-group">-->
<!--                                <span>学员类型：</span>-->
<!--                                <select name="is_test" id="">-->
<!--                                    <option value="">请选择</option>-->
<!--                                    --><?php //foreach ($studenttype as $sk=>$sv){ ?>
<!--                                        <option value="--><?php //xcho($sv['dict_value']) ?><!--">--><?php // xcho($sv['cn_name'])?><!--</option>-->
<!--                                    --><?php //} ?>
<!--                                </select>-->
<!--                            </div>-->
<!--                        </div>-->
                        <div class="col-xs-4">
                            <div class="input-group">
                                <span>班主任：</span>
                                <select name="cr_id" id="">
                                    <option value="">请选择</option>
                                    <?php foreach ($crlist as $cr){ ?>
                                        <option value="<?php xcho($cr['id']) ?>"><?php  xcho($cr['full_name'])?></option>
                                    <?php } ?>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <h3>同步信息</h3>
            <div class="cont-form">
                <div class="form-row">
                    <div class="row">
                        <div class="col-xs-4">
                            <div class="input-group">
                                <span class="input-group-addon">天王星学员ID：</span>
                                <input type="text" class="form-control int" name="twx_id" placeholder="天王星学员ID">
                            </div>
                        </div>
                        <div class="col-xs-4">
                            <div class="input-group">
                                <span class="input-group-addon">官网学员ID：</span>
                                <input type="text" class="form-control int" name="gw_id" placeholder="官网学员ID">
                            </div>
                        </div>
                        <div class="col-xs-4">
                            <div class="input-group">
                                <span class="input-group-addon">学员账号：</span>
                                <input type="text" class="form-control" name="gw_account" placeholder="学员账号">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-row">
                    <div class="row">
                        <div class="col-xs-4">
                            <div class="input-group">
                                <span class="input-group-addon">学员密码：</span>
                                <input type="text" class="form-control" name="gw_password" placeholder="天王星学员ID">
                            </div>
                        </div>
                        <div class="col-xs-4">
                            <div class="input-group">
                                <span class="input-group-addon">推荐人：</span>
                                <input type="text" class="form-control int" name="introducer_id" placeholder="推荐人id">
                            </div>
                        </div>
                    </div>
                </div>


            </div>
            <h3>系统信息</h3>
            <div class="cont-form">
                <div class="form-row">
                    <div class="row">
                        <div class="col-xs-4">
                            <div class="input-group">
                                <span>CC负责人：</span>
                                <select name="cc_id" id="">
                                    <option value="">请选择</option>
                                    <?php foreach ($aCcList as $cc) { ?>
                                        <option value="<?php xcho($cc['id']) ?>"><?php xcho($cc['full_name']) ?></option>
                                    <?php } ?>
                                </select>
                            </div>
                        </div>
                        <div class="col-xs-4">
                            <div class="input-group">
                                <span>TMK负责人：</span>
                                <select name="tmk_id" id="">
                                    <option value="">请选择</option>
                                    <?php foreach ($aTmkList as $tmk) { ?>
                                    <option value="<?php xcho($tmk['id']) ?>"><?php xcho($tmk['full_name']) ?></option>
                                    <?php } ?>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div>
                        <div class="col-xs-4">
                            <div class="basemess-cont">
                                <p>联系备注：</p>
                                <textarea name="remark" id="" cols="100" rows="3"></textarea>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="addCourse-btn">
                <div class="addCourse-btn-cont">
                    <button id="cancel">取消</button>
                    <button id="save">确定</button>
                </div>
            </div>
        </div>
    </div>
</div>
<input type="hidden" name="save_user" value="<?php xcho($saveStudent) ?>"/>

<script src="<?php xcho(loadSource('/assets/plugins/jquery/jquery.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/bootstrap/js/bootstrap.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/data-table/media/js/jquery.dataTables.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/data-table/media/js/dataTables.bootstrap.min.js')) ?>"></script>
<script
    src="<?php xcho(loadSource('/assets/plugins/data-table/extensions/Responsive/js/dataTables.responsive.min.js')) ?>"></script>
<script
    src="<?php xcho(loadSource('/assets/plugins/data-table/extensions/Responsive/js/responsive.bootstrap.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets//plugins/ztree/js/jquery.ztree.core.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/layui/layui.all.js')) ?>" charset="utf-8"></script>
<script type="text/javascript" src="<?php xcho(loadSource('/assets//plugins/ztree/js/jquery.ztree.excheck.js')) ?>"></script>
<script type="text/javascript" src="<?php xcho(loadSource('/assets//plugins/ztree/js/jquery.ztree.exedit.js')) ?>"></script>
<script type="text/javascript"
        src="<?php xcho(loadSource('/assets/js/validate.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/js/city.js')) ?>"></script>
<script>
    $(function () {

        addressInit('cmbProvince', 'cmbCity', 'cmbArea');
        $("#cancel").on("click",function () {
//            window.history.go(-1);  //不能原路返回，之后修改
            location.href = "/student/student/index"
            //window.parent.$('#index_tabs').tabs('close','添加学员');
        });
        $("#save").on("click", function () {
            var isContine = validateF();
            if(!isContine) return false;
            var param = {};
            var stu_relation = {};
            param.sname = $("input[name='sname']").val();
            console.log(param.sname);
            param.cellphone = $("input[name='cellphone']").val();
            param.telephone = $("input[name='telephone']").val();
            param.sex = $("select[name='sex']").val();
            param.age = $("input[name='age']").val();
            param.wechat = $("input[name='wechat']").val();
            param.qq = $("input[name='qq']").val();
            param.email = $("input[name='email']").val();
            param.channel_id = $("select[name='channel_id']").val();
            param.province = $("select[name='province']").val();
            param.city = $("select[name='city']").val();
            param.county = $("select[name='county']").val();
            param.home_address = $("input[name='home_address']").val();
            param.admission_time = $("input[name='admission_time']").val();
            param.school = $("input[name='school']").val();
            param.grade = $("select[name='grade']").val();
            param.intention = $("select[name='intention']").val();
//            param.is_test = $("select[name='is_test']").val();
            param.twx_id = $("input[name='twx_id']").val();
            param.gw_id = $("input[name='gw_id']").val();
            param.gw_account = $("input[name='gw_account']").val();
            param.gw_password = $("input[name='gw_password']").val();
            param.cc_id = $("select[name='cc_id']").val();
            param.tmk_id = $("select[name='tmk_id']").val();
            param.is_treasure = 'no';
            param.cr_id = $("select[name='cr_id']").val();
            param.remark = $("textarea[name='remark']").val();
            param.introducer_id = $("textarea[name='introducer_id']").val();

            stu_relation = {
                0:{
                    relation:$("input[name='relation1']").val(),
                    full_name:$("input[name='full_name1']").val(),
                    cellphone:$("input[name='re_cellphone1']").val()
                },
                1:{
                    relation:$("input[name='relation2']").val(),
                    full_name:$("input[name='full_name2']").val(),
                    cellphone:$("input[name='re_cellphone2']").val(),
                },
                2:{
                    cellphone:$("input[name='cellphone']").val(),
                }
            }
            param.stu_relation = stu_relation;
            $.ajax({
                url: $("input[name='save_user']").val(),
                type: 'post',
                data:param,
                dataType: 'json',
                success: function (data) {
                    if(data.success == 1){
                        location.href = "/student/student/index";
                    }else{
                        layer.alert(data.msg);
                        console.log(data.errors);
                        var errors = data.errors;
                        for(var i in errors){
//                            $("span.hidden_area").css("display","none")
                            $("span.hidden_area").each(function () {
                                console.log($(this).attr("data-name")==i);
                                if($(this).attr("data-name")==i){
                                    $(this).css("display","block");
                                    $(this).html(errors[i].message);
                                    layer.alert(errors[i].message);
                                }
                            })
                        }
                    }
                },
                complete:function(){

                },
                error: function () {

                }
            });
        });
    });
</script>
<?php include_once TPL_PATH . 'public/foot_script.phtml'; ?>
<button id="top" style="height: 50px;width: 50px;"></button></body>

</html>
